import Vue from 'vue';
import Router from 'vue-router';
import Home from '@/pages/home'
import Index from '@/pages/index'
import Product from '@/pages/product'
import Detail from '@/pages/detail'
import Cart from '@/pages/cart'
import Order from '@/pages/order'
import OrderConfirm from '@/pages/orderConfirm'
import OrderList from '@/pages/orderList'
import OrderPay from '@/pages/orderPay'
import Alipay from '@/pages/alipay'


Vue.use(Router)

export default new Router({
    routes: [{
            // 根组件
            path: '/',
            name: 'home',
            // 重定向
            redirect:'/index',
            component: Home,
            // 子组件
            children: [
                {
                    path: '/index',
                    name: 'index',
                    component: Index,
                },
                {
                    path: '/product/:id',
                    name: 'product',
                    component: Product,
                },
                {
                    path: '/detail/:id',
                    name: 'detail',
                    component: Detail,
                },
            ]
        },
        {
            // 根组件
            path: '/cart',
            name: 'cart',
            component: Cart,
        },
        {
            // 根组件
            path: '/order',
            name: 'order',
            component: Order,
            // 子组件
            children: [
                {
                    path: 'confirm',
                    name: 'order-confirm',
                    component: OrderConfirm,
                }, {
                    path: 'list',
                    name: 'order-list',
                    component: OrderList,
                },
                {
                    path: 'pay',
                    name: 'order-pay',
                    component: OrderPay,
                },
                {
                    path: 'alipay',
                    name: 'alipay',
                    component: Alipay,
                }
            ]
        },
    ]
});